//
//  JHBaseViewController.h
//  JuniRengLish_iOS
//
//  Created by revogi on 2019/5/8.
//  Copyright © 2019 revogi. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef void(^AlertButtonHandler)(UIAlertAction *action);
typedef void(^AlertControllerHandler)(UIAlertController *alertController);

@interface JHBaseViewController : UIViewController
- (void)initUI;

- (void)requestData;

- (void)showLoadingDialog:(BOOL)animated;

- (void)showLoadingDialogWithTitle:(NSString*)title;

- (void)showLoadingDialog:(NSString*)title animated:(BOOL)animated;

- (void)showLoadingDialog:(NSString*)title message:(NSString*)message animated:(BOOL)animated;

- (void)dismissLoadingDialog:(BOOL)animated;

- (void)showProgressDialog:(NSString*)title message:(NSString*)message progress:(float)progress;

- (void)dismissProgressDialog:(BOOL)animated;

- (void)dismissAllHUD:(BOOL)animated;

- (void)showAlertOK:(NSString*)title message:(NSString*)message;

- (void)showAlertOK:(NSString*)title message:(NSString*)message handler:(AlertButtonHandler)handler;

- (void)showAlertOK:(NSString*)title message:(NSString*)message buttonText:(NSString*)button handler:(AlertButtonHandler)handler;

-(void)showAlert:(NSString *)title
message:(NSString *)message
   buttonHandler:(AlertButtonHandler)handler;

- (void)showAlert:(NSString*)title
          message:(NSString*)message
       buttonText:(NSString*)buttonText
    buttonHandler:(AlertButtonHandler)handler
       cancelText:(NSString*)cancelText
    cancelHandler:(AlertButtonHandler)cancelHandler;

- (void)showAlert:(NSString*)title
       inputField:(AlertControllerHandler)inputHandler
       buttonText:(NSString*)buttonText
    buttonHandler:(AlertButtonHandler)handler
       cancelText:(NSString*)cancelText
    cancelHandler:(AlertButtonHandler)cancelHandler;

- (void)showAlert:(NSString*)title message:(NSString*)message buttons:(NSArray*)buttons;

- (void)showSheet:(NSString *)title message:(NSString *)message buttons:(NSArray*)buttons;

+ (UIAlertController*)alertViewControllerWithTitle:(NSString*)title
                                           message:(NSString*)message
                                        buttonText:(NSString*)buttonText
                                     buttonHandler:(AlertButtonHandler)handler
                                        cancelText:(NSString*)cancelText
                                     cancelHandler:(AlertButtonHandler)cancelHandler;

+ (UIAlertController*)alertViewControllerWithTitle:(NSString*)title message:(NSString*)message buttons:(NSArray*)buttons;
+ (UIAlertController*)sheetViewControllerWithTitle:(NSString*)title message:(NSString*)message buttons:(NSArray*)buttons;

@end

@interface AlertButton : NSObject

@property (nonatomic, strong) NSString *buttonString;
@property (nonatomic, assign) UIAlertActionStyle style;
@property (nonatomic, assign) AlertButtonHandler handler;

+ (id)initWithText:(NSString*)title handler:(AlertButtonHandler)handler;

+ (id)initWithText:(NSString*)title style:(UIAlertActionStyle)style handler:(AlertButtonHandler)handler;

@end
